package com.homework.zuoye3;

import java.util.ArrayList;

public class TestCoder {
    public static void main(String[] args) {
        Coder coder1 = new Coder("王宝强", 25, "打篮球");
        Coder coder2 = new Coder("汪峰", 35, "游泳");
        Coder coder3 = new Coder("李铁", 19, "踢足球");
        Coder coder4 = new Coder("姚明", 18, "击剑");
        ArrayList<Coder> coders = new ArrayList<>();
        coders.add(coder1);
        coders.add(coder2);
        coders.add(coder3);
        coders.add(coder4);
        for (int i = 0; i < coders.size(); i++) {
            Coder coder = coders.get(i);
            if(coder.getAge() > 30){
                coder.setLike("打保龄球");
                System.out.println(coder.getName()+"----"+coder.getAge()+"----"+coder.getLike());
            }else if(coder.getAge() < 20){
                coders.remove(i);
            }else{
                System.out.println(coder.getName()+"----"+coder.getAge()+"----"+coder.getLike());
            }
        }

    }
}
